package com.hitqz.robot.biz.controller;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hitqz.robot.api.business.enums.BrandEnum;
import com.hitqz.robot.api.business.model.vo.robot.RobotEquipmentVo;
import com.hitqz.robot.api.common.entity.RobotEquipment;
import com.hitqz.robot.common.core.util.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * @author xupkun
 * @date 2025/3/5
 */

@RestController
@RequiredArgsConstructor
@RequestMapping("/robotEquipment")
@Tag(name = "外设数据管理")
@Slf4j
public class RobotEquipmentController {


    @GetMapping("/listEquipmentEnum/oilPlc" )
    @Operation(summary = "单独读取取油柜-PLC数据")
    public R<Page<RobotEquipmentVo>> listEquipmentEnum(@ParameterObject Page page) {
        LambdaQueryWrapper<RobotEquipment> wrapper = Wrappers.lambdaQuery();
        wrapper.eq(RobotEquipment::getBrand,  BrandEnum.OIL_PLC.getEnStr());
        //List<RobotEquipment> list = robotEquipmentService.list(wrapper);
        List<RobotEquipment> list = new ArrayList<>();
        RobotEquipment robotEquipment = new RobotEquipment();
        robotEquipment.setId(1L);
        robotEquipment.setName("取油柜1");
        robotEquipment.setBrand("变压器取油柜");
        robotEquipment.setType(5);
        list.add(robotEquipment);
        List<RobotEquipmentVo> voList = BeanUtil.copyToList(list, RobotEquipmentVo.class);
        Page<RobotEquipmentVo> voPage = new Page<>(page.getCurrent(), page.getSize());
        voPage.setTotal(1);
        voPage.setRecords(voList);
        return R.ok(voPage);
    }

}
